#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int func(char* arr,int begin,int end){
    char numarr[10],s[10000]={0},temp[1000]={0};
    int numlen=0;
    for(int i=begin;i<end;i++){
        if(arr[i]=='|') break;
        numarr[numlen++]=arr[i];
    }
    numarr[numlen]='\0';
    int num = atoi(numarr);
    int cur=num,count=0;
    while (cur != 0){
        cur /= 10;
        count++;
    }
    strncpy(temp,arr+begin+count+1,end-begin-count);
    for(int i=0;i<num;i++){
        strcat(s,temp);
    }
    int len=strlen(s);
    arr[begin]='\0';
    strcat(arr,s);
    return begin+len-1;
}

int main(){
    char str[1001];
    scanf("%[^\n]",str);
    char* charstack=(char*)malloc(10000*sizeof(char));
    char flag[200];
    int chartop=-1,flagtop=-1;
    int len=strlen(str);
    for (int i=0;i<len;i++){
        if(str[i]=='['){
            flag[++flagtop]=chartop;
        } 
        else if(str[i]!=']' && str[i]!='['){
            charstack[++chartop]=str[i];
        }
        else if(str[i]==']'){
            chartop=func(charstack,flag[flagtop]+1,chartop);
            flagtop--;
        }
    }
    charstack[chartop+1]='\0';
    printf("%s\n",charstack);
    free(charstack);
    return 0;
}